#include <stdio.h>
#include <stdlib.h>
#include "sort.h"

int bubble_sort(int *data, int size){
    for(int i = 0; i < size - 1; i++){
        for(int j = 0; j < size -1 - i; j++){
            if(data[j+1]<data[j]){
                int tmp = data[j+1];
                data[j+1]  = data[j];
                data[j] = tmp;
            }
        }
    }
    return 0;
}

int partition(int *data, int low, int high){
    int item = data[low];
    while(low < high){
        while(low < high && data[high] >= item)
            high--;
        data[low] = data[high];
        while(low < high && data[low] <= item)
            low++;
        data[high] = data[low];
    }
    data[low] = item;
    return low;
}

int quick_sort(int *data, int low, int high){
    if(low < high){
        int index = partition(data, low, high);
        quick_sort(data, low, index - 1);
        quick_sort(data, index + 1, high);
    }
    return 0;
}